module.exports = (app) => {
  const { STRING, INTEGER, DECIMAL, DATE, NOW } = app.Sequelize

  const User = app.model.define(
    't_user',
    {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comment: '用户表主键'
      },
      nickname: {
        type: STRING,
        allowNull: false,
        defaultValue: '',
        comment: '用户名'
      },
      email: {
        type: STRING,
        allowNull: false,
        defaultValue: '',
        comment: '邮箱'
      },
      password: {
        type: STRING,
        allowNull: false,
        defaultValue: '',
        comment: '密码'
      },
      balance: {
        type: DECIMAL(8, 2),
        allowNull: false,
        defaultValue: 0,
        comment: '余额'
      },
      role: {
        type: INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: '角色0：用户 1：商家'
      },
      created_at: {
        type: DATE,
        allowNull: false,
        defaultValue: NOW,
        comment: '创建时间'
      },
      updated_at: {
        type: DATE,
        allowNull: false,
        defaultValue: NOW,
        comment: '更新时间'
      }
    },
    {
      freezeTableName: true, // Model 对应的表名将与model名相同
      timestamps: false
    }
  )
  return User
}
